<template>
  <div v-waves class="list-container">
    <div class="news_desc" :class="[`${imgOri}_img`]">
      <div class="desc_left">
        <img :src="src" alt="">
      </div>
      <div class="desc_right">
        <template v-if="!$slots.txt">
          <h3 :class="double ? 'clamp3' : 'clamp2'">{{ title }}</h3>
          <div v-if="!double" class="news_info j-space-between">
            <span class="news_data">{{ date }}</span>
            <div class="right">
              <span class="news_click"> {{ ping }}</span>
              <span class="news_click"> {{ zan }}</span>
            </div>
          </div>
        </template>
        <template v-else>
          <slot name="txt" />
        </template>
      </div>
      <div v-if="double" class="news_info j-space-between">
        <template v-if="!$slots.bottom">
          <span class="news_data">{{ date }}</span>
          <div class="right">
            <span class="news_click"> {{ ping }} </span>
            <span class="news_click"> {{ zan }} </span>
          </div>
        </template>
        <template v-else>
          <slot name="bottom" />
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import waves from '@/directive/waves/index.js' // 水波纹指令
export default {
  name: 'GList',
  directives: {
    waves
  },
  props: {
    double: {
      type: Boolean,
      default: false
    },
    src: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
    },
    imgOri: {
      type: String,
      default: 'right'
    },
    date: {
      type: String,
      default: ''
    },
    ping: {
      type: Number,
      default: 0
    },
    zan: {
      type: Number,
      default: 0
    }
  }
}
</script>

<style lang="scss" scoped>
.list-container {
  .news_desc {
    display: flex;
    padding: 15Px;
    border-bottom: 1Px solid #e8e8e8;
    flex-wrap: wrap;
    &.left_img {
      flex-direction: row-reverse;
      .desc_left {
        margin-left: 16Px;
      }
    }
    &.right_img {
      flex-direction: row;
      .desc_left {
        margin-right: 16Px;
      }
    }
    .desc_left {
      float: left;
      overflow: hidden;
      img {
        width: 120Px;
        border-radius: 4Px;
      }
    }
    .desc_right {
      float: left;
      width: calc(100% - 140Px);
      height: 85Px;
      position: relative;
      text-align: left;
      h3 {
        font-size: 16Px;
        color: #23222d;
        font-weight: 700;
        line-height: 30Px;
        display: -webkit-box;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-box-orient: vertical;
        margin: 0;
      }
      .clamp2 {
        font-size: 16Px;
        -webkit-line-clamp: 2;
      }
      .clamp3 {
        font-size: 16Px;
        -webkit-line-clamp: 3;
      }
    }
    .news_info {
      font-size: 12Px;
      color: #999;
      margin-top: 14Px;
      min-height: 16Px;
      display: flex;
      width: 100%;
      .right {
        width: 120Px;
        display: flex;
        justify-content: space-between;
      }
      &.j-space-between {
        justify-content: space-between;
      }
      &.j-flex-start {
        justify-content: flex-start;
        span {
          margin-right: 10Px;
        }
      }
    }
  }
}
</style>
